{% extends "hs-base.html" %}
{% block div %}
    <div class="content">
                    <div class="container-fluid">

                        <div class="row">
                            <div class="col-12">
                                <div class="card-box">
                                    <h4 class="header-title">docker 升级中心</h4>
                                    <br>

                                    <table class="table table-hover m-0 tickets-list table-actions-bar dt-responsive nowrap" cellspacing="0" width="100%" id="datatable">
                                        <thead>
                                        <tr>
                                            <th>
                                                序号
                                            </th>
                                            <th>升级地址</th>
                                            <th>升级程序</th>
                                            <th>升级人</th>
                                            <th class="text-center">升级状态</th>


                                        </tr>
                                        </thead>

                                        <tbody>
                                        {% for turn_list in turn_lists %}
                                            <tr>
                                            <td><b>#{{ turn_list[0] }}</b></td>
                                            <td>{{ turn_list[1] }}</td>
                                            <td>{{ turn_list[3] }}</td>


                                            <td>{{ turn_list[5] }}</td>

                                                {% if loop.index == 1 %}
                                                    <td class="text-center">
                                                        <progress id="myProgress" max="100" value="0"></progress>
                                                        <br>
                                                        <span id="mySpan"></span>
                                                        <input type="hidden" id="my_id" value="{{ turn_list[0] }}">
                                                    </td>
                                                {% else %}
                                                    {% if hs_current_user == turn_list[5] %}
                                                        <td class="text-center"><a href="javascript: void(0);" class="table-action-btn dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a></td>
                                                    {% else %}
                                                        <td>无法操作</td>>
                                                    {% endif %}
                                                {% endif %}



                                        </tr>
                                        {% endfor %}

                                        </tbody>
                                    </table>
                                </div>
                                <div class="card-box">
                                    <h4 class="header-title">产研 升级中心</h4>
                                    <br>

                                    <table class="table table-hover m-0 tickets-list table-actions-bar dt-responsive nowrap" cellspacing="0" width="100%" id="datatable">
                                        <thead>
                                        <tr>
                                            <th>
                                                序号
                                            </th>
                                            <th>升级地址</th>
                                            <th>升级版本</th>
                                            <th>升级程序</th>
                                            <th>升级人</th>
                                            <th>升级状态</th>


                                        </tr>
                                        </thead>

                                        <tbody>
                                        {% for bop_turn_list in bop_turn_lists %}
                                            <tr>
                                            <td><b>#{{ bop_turn_list[0] }}</b></td>
                                            <td>{{ bop_turn_list[1] }}</td>
                                            <td>{{ bop_turn_list[2] }}</td>
                                            <td>{{ bop_turn_list[3] }}</td>
                                            <td>{{ bop_turn_list[4] }}</td>
                                            {% if hs_current_user == bop_turn_list[4] %}
                                                <td>
                                                <div class="btn-group dropdown">
                                                    <a href="javascript: void(0);" class="table-action-btn dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
                                                    <div class="dropdown-menu dropdown-menu-right">
                                                        <a class="dropdown-item" href="#"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit Ticket</a>
                                                        <a class="dropdown-item" href="#"><i class="mdi mdi-check-all mr-2 text-muted font-18 vertical-middle"></i>Close</a>
                                                        <a class="dropdown-item" href="#"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Remove</a>
                                                        <a class="dropdown-item" href="#"><i class="mdi mdi-star mr-2 font-18 text-muted vertical-middle"></i>Mark as Unread</a>
                                                    </div>
                                                </div>
                                            </td>
                                            {% else %}
                                                <td>无法操作</td>>
                                            {% endif %}
                                        </tr>
                                        {% endfor %}

                                        </tbody>
                                    </table>
                                </div>
                            </div><!-- end col -->
                        </div>
                        <!-- end row -->

                    </div> <!-- container -->

                </div>


{% endblock %}
{% block script %}
    <script type="text/javascript">

        var getting = {

                type:'POST',
                data:{fun:'change',table_id:document.getElementById("my_id").value},
                success:function(data) {
                    var myProgress = document.getElementById("myProgress");
                    var mySpan = document.getElementById("mySpan");
                    var value = myProgress.value;

                    myProgress.value = data.value;
                    mySpan.innerText = data.progress;
                    if (data.value == 100){
                        window.location.reload()
                    }

                  setTimeout(function(){$.ajax(getting);},2000);//2秒后定时发送请求
                }
        };
        $.ajax(getting)

    </script>
{% endblock %}